const joi = require('joi')

// 文章标题
const title = joi.string().min(1).max(50).required()

// 引文
const excerpt = joi.string().min(1).required()

// 内容
const content = joi.string().min(1).required()

// 封面
const cover = joi.string().dataUri()

// 用户id
const userId = joi.number().integer().min(1).required()

// 专栏id
const columnId = joi.number().integer().min(1).required()

// 文章id
const id = joi.number().integer().min(1).required()

// 当前页
const currentPage = joi.number().integer().min(1)

// 页码大小
const pageSize = joi.number().integer().min(1)

exports.add_article_schema = {
    body: {
        title,
        excerpt,
        content,
        cover,
        userId,
        columnId
    }
}

exports.get_article_schema = {
    params: {
        id
    }
}

exports.list_article_schema = {
    params: {
        columnId: id
    },
    query: {
        currentPage,
        pageSize
    }
}

exports.update_article_schema = {
    body: {
        id,
        title,
        content,
        cover
    }
}